package com.wtp.wallpaper.aspect.processor;

import com.wtp.wallpaper.pojo.entity.UserUpload;
import com.wtp.wallpaper.pojo.vo.*;

import java.util.function.Function;

// 2. 实现各VO类型的处理器
class PictureProcessor implements UrlProcessor<PictureVO> {
    @Override
    public Class<PictureVO> getSupportedType() {
        return PictureVO.class;
    }

    @Override
    public void process(PictureVO vo, Function<String, String> urlResolver) {
        vo.setPicurl(urlResolver.apply(vo.getPicurl()));
        vo.setSmallpicurl(urlResolver.apply(vo.getSmallpicurl()));
    }
}
class ClassifyProcessor implements UrlProcessor<ClassifyVO> {
    @Override
    public Class<ClassifyVO> getSupportedType() {
        return ClassifyVO.class;
    }

    @Override
    public void process(ClassifyVO vo, Function<String, String> urlResolver) {
        vo.setPicurl(urlResolver.apply(vo.getPicurl()));
    }
}

class BannerPicProcessor implements UrlProcessor<BannerPicVO> {
    @Override
    public Class<BannerPicVO> getSupportedType() {
        return BannerPicVO.class;
    }

    @Override
    public void process(BannerPicVO vo, Function<String, String> urlResolver) {
        vo.setPicurl(urlResolver.apply(vo.getPicurl()));
    }
}

class PicurlProcessor implements UrlProcessor<PicurlVO>{

    @Override
    public Class<PicurlVO> getSupportedType() {
        return PicurlVO.class;
    }

    @Override
    public void process(PicurlVO vo, Function<String, String> urlResolver) {
        vo.setTempUrl(urlResolver.apply(vo.getSmallpicurl()));
    }
}

class UserUploadProcessor implements UrlProcessor<UserUploadVO>{

    @Override
    public Class<UserUploadVO> getSupportedType() {
        return UserUploadVO.class;
    }

    @Override
    public void process(UserUploadVO vo, Function<String, String> urlResolver) {
        vo.setPicurl(urlResolver.apply(vo.getPicurl()));
    }

}